fix(config): strip defaults#9
Conversation
commit: |
There was a problem hiding this comment.
Pull request overview
This pull request adds functionality to strip default configuration values when writing to package.json, helping keep configuration files lean. The main change is the introduction of a stripDefaultConfigValues() function that removes properties matching default values, along with its application in the add, init, and remove commands when writing package.json configs. The PR also adds a fallback path for loading the tool version from package.json and includes tests for both the stripping behavior and tool version detection.
Changes:
- Added
stripDefaultConfigValues()function to remove config properties that match default values - Applied stripping in
add,init, andremovecommands when writing package.json (not standalone config files) - Added fallback package.json resolution path (
../../package.json) inloadToolVersion()for bundled code - Added tests verifying package.json configs omit default fields and tool version detection works
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/config.ts | Adds stripDefaultConfigValues() function and isEqualStringArray() helper to remove default values from config |
| src/add.ts | Applies stripDefaultConfigValues() when writing package.json configs |
| src/init.ts | Applies stripDefaultConfigValues() when writing package.json configs |
| src/remove.ts | Applies stripDefaultConfigValues() when writing package.json configs |
| src/sync.ts | Adds fallback to ../../package.json for finding tool version in bundled builds |
| tests/cli-add.test.js | Adds test verifying package.json configs don't include default fields |
| tests/sync-tool-version.test.js | Adds test verifying lock file contains correct tool version from package.json |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Remove default values when writing config to keep files lean.
Changes
stripDefaultConfigValues()function to remove config properties matching defaultsadd,init, andremovecommands when writing package.jsonloadToolVersion()